package com.struts2.action;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Restrictions;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2.model.Category;
import com.struts2.model.Color;
import com.struts2.model.Designer;
import com.struts2.model.Gender;
import com.struts2.model.Invoice;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.model.Season;
import com.struts2.model.Size;
import com.struts2.model.Type;
import com.struts2.service.AdminService;

public class AdminDesignerAction extends ActionSupport implements
		ModelDriven<List<Designer>>, SessionAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	// For SessionAware
	private Map<String, Object> session;

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	private List<Designer> designers;

	private Designer designer;
	
	private List<Product_line> product_lines;
	private int id;

	private String name;
	private String address;
	private String background;
	private String gender;
	private String email;
	private int phone_number;
	private String education;
	private Long bank_account_number;
	private String username;
	
	private boolean approval;

	public String execute() {

		AdminService as = new AdminService();
		designers = as.getDesigners(designers);
		return "1";
	}

	public String edit() {
		AdminService as = new AdminService();
		designer = as.getDesigner(id);

		product_lines = as.getProduct_linesByDesigner(designer);
		return SUCCESS;
	}

	public String save() {
		AdminService as = new AdminService();
		as.setDesigner(id, name, background, address, gender, email, phone_number,
				education, bank_account_number, username, approval);

		designers = as.getDesigners(designers);
		
		
		session.put("DesignersNotApproval", as.getDesignerNotApproval());

		return SUCCESS;
	}
	
	public String approval() {
		AdminService as = new AdminService();
		as.setDesignerApporval(id);
		
		designers = as.getDesigners(designers);
		session.put("DesignersNotApproval", as.getDesignerNotApproval());

		
		return SUCCESS;
	}
	

	@Override
	public List<Designer> getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public List<Designer> getDesigners() {
		return designers;
	}

	public void setDesigners(List<Designer> designers) {
		this.designers = designers;
	}

	public Designer getDesigner() {
		return designer;
	}

	public void setDesigner(Designer designer) {
		this.designer = designer;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getPhone_number() {
		return phone_number;
	}

	public void setPhone_number(int phone_number) {
		this.phone_number = phone_number;
	}

	public String getEducation() {
		return education;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public Long getBank_account_number() {
		return bank_account_number;
	}

	public void setBank_account_number(Long bank_account_number) {
		this.bank_account_number = bank_account_number;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public boolean isApproval() {
		return approval;
	}

	public void setApproval(boolean approval) {
		this.approval = approval;
	}

	public String getBackground() {
		return background;
	}

	public void setBackground(String background) {
		this.background = background;
	}

	public List<Product_line> getProduct_lines() {
		return product_lines;
	}

	public void setProduct_lines(List<Product_line> product_lines) {
		this.product_lines = product_lines;
	}

	
	// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

}
